from manim import *



class math1(MovingCameraScene):
    def construct(self):
        self.camera.background_color = BLACK  # 设置背景颜色
        self.camera.frame_width = 100  # 设置边框宽度
        self.camera.frame_height = 60  # 设置边框高度
        self.camera.pixel_height = 1080  # 设置像素高度
        self.camera.pixel_width = 1920  # 设置像素宽度
        self.camera.center = ORIGIN  # 设置中心点位置
        self.camera.scale_factor = 1.0  # 设置缩放因子
        #设置横线
        for i in range(6*2+1):       
            dot1=Dot([-50,5*(i-6),0]).set_opacity(0.5)
            dot2=Dot([50,5*(i-6),0]).set_opacity(0.5)
            if i==6:
                line1=Line(dot1,dot2).set_color(WHITE).set_opacity(0.5)
                
            else:
                line1=Line(dot1,dot2).set_color(WHITE).set_opacity(0.5)
               
            self.add(dot1,dot2,line1)
        #设置竖线
        for i in range(10*2+1):        
            dot3=Dot([(i-10)*5,-30,0]).set_opacity(0.5)
            dot4=Dot([(i-10)*5,30,0]).set_opacity(0.5)
            if i==10:
                line2=Line(dot3,dot4).set_color(WHITE).set_opacity(0.5)
                
            else:
                line2=Line(dot3,dot4).set_color(WHITE).set_opacity(0.5)
            self.add(dot3,dot4,line2)
        #设置三个点
        dot1 = Dot(radius=1, color=RED)  
        dot1.move_to([-47.5,27.5,0]) 
        dot2 = Dot(radius=1, color=YELLOW)  
        dot2.move_to([-42.5,27.5,0])  
        dot3 = Dot(radius=1, color=GREEN)  
        dot3.move_to([-37.5,27.5,0])
        #镜头跟进效果
        self.camera.frame.save_state()
        self.play(FadeIn(dot1),FadeIn(dot2),FadeIn(dot3))
        self.wait()
         #中心主题+框框标记
        text1 = Tex(r"\text{不定积分计算}",color=PINK
                   ,tex_template=TexTemplateLibrary.ctex).scale(5.0).move_to([-30,5,0])
        rectangle=Rectangle(color=BLUE,fill_opacity=0.0,width=23,height=5
                            ,stroke_color=BLUE,stroke_width=20)
        rectangle.move_to([-30, 5, 0])




        #百分之90+，动态更新效果

       # 创建一个 DecimalNumber 对象，初始值为 0
        number = DecimalNumber(0, num_decimal_places=0, color=YELLOW)

        # 设置数字的位置
        number.move_to([0,5,0]).scale(20)

        # 添加到场景中
        self.add(number)


        # 等待一段时间
        self.wait(1)
        self.play(FadeOut(number),Create(rectangle),Create(text1),ChangeDecimalToValue(number, 90), run_time=1)
        
        





        #箭头引出
        arrow = Arrow(start=[-18,7.5,0],end=[-10,20,0], color=RED
                       , stroke_width=20, tip_length=1)
        #文本2
        text2 = Tex(r"\text{凑微分}"
                   ,tex_template=TexTemplateLibrary.ctex).scale(5.0).move_to([-2.5,20,0])
    

        #箭头1引出
        arrow1 = Arrow(start=[-18,6,0],end=[-10,14,0], color=RED
                       , stroke_width=20, tip_length=1)
        #文本3
        text3 = Tex(r"\text{换元法}"
                   ,tex_template=TexTemplateLibrary.ctex).scale(5.0).move_to([-2.5,14,0])
        
        #箭头2引出
        arrow2 = Arrow(start=[-18,5,0],end=[-10,9,0], color=RED
                       , stroke_width=20, tip_length=1)
        #文本4
        text4 = Tex(r"\text{分部积分}"
                   ,tex_template=TexTemplateLibrary.ctex).scale(5.0).move_to([-2.5,9,0])

        #箭头3引出
        arrow3 = Arrow(start=[-18,3,0],end=[-10,2,0], color=RED
                       , stroke_width=20, tip_length=1)
        #文本5
        text5= Tex(r"\text{裂项法}"
                   ,tex_template=TexTemplateLibrary.ctex).scale(5.0).move_to([-2.5,2,0])
        #箭头4引出
        arrow4 = Arrow(start=[-18,1,0],end=[-10,-5,0], color=RED
                       , stroke_width=20, tip_length=1)
        #文本6
        text6= Tex(r"\text{重要题型}"
                   ,tex_template=TexTemplateLibrary.ctex).scale(5.0).move_to([-2.5,-5,0])
        

        #集中展现
        self.play(Create(arrow4),Create(arrow3),Create(arrow2),Create(arrow1),Create(arrow))
        self.play(Write(text6),Write(text5),Write(text4),Write(text3),Write(text2))

         #半透明矩阵扩展
        rectangle1=Rectangle(color=YELLOW,fill_opacity=0.3,width=1,height=5
                            ,stroke_color=YELLOW,stroke_width=0).move_to([-2.5,-5,0])
        self.play(
            rectangle1.animate.stretch(10,dim=0)
        )



        #箭头引出
        arrow5 = Arrow(start=[5,-3,0],end=[12,5,0], color=RED
                       , stroke_width=20, tip_length=1)
        #文本2
        text7 = Tex(r"\text{有理函数}"
                   ,tex_template=TexTemplateLibrary.ctex).scale(5.0).move_to([17,5,0])

        #箭头1引出
        arrow6 = Arrow(start=[5,-5,0],end=[12,0,0], color=RED
                       , stroke_width=20, tip_length=1)
        #文本3
        text8 = Tex(r"\text{无理函数}"
                   ,tex_template=TexTemplateLibrary.ctex).scale(5.0).move_to([17,0,0])


        #箭头2引出
        arrow7 = Arrow(start=[5,-7,0],end=[12,-10,0], color=RED
                       , stroke_width=20, tip_length=1)
        #文本4
        text9 = Tex(r"\text{三角函数}"
                   ,tex_template=TexTemplateLibrary.ctex).scale(5.0).move_to([17,-10,0])

        text10 = Tex(r"\text{（裂项法）}"
                   ,tex_template=TexTemplateLibrary.ctex).scale(5.0).next_to(text7,RIGHT,buff=1)

        text11 = Tex(r"\text{（整体换元）}"
                   ,tex_template=TexTemplateLibrary.ctex).scale(5.0).next_to(text8,RIGHT,buff=1)
        #集中展现

        self.play(Create(arrow7),Create(arrow6),Create(arrow5))
        self.play(Write(text11),Write(text10),Write(text9),Write(text8),Write(text7))
        #半透明矩阵扩展
        rectangle2=Rectangle(color=GREEN,fill_opacity=0.3,width=1,height=5
                            ,stroke_color=GREEN,stroke_width=0).move_to([17,-10,0])
        self.play(
            rectangle2.animate.stretch(10,dim=0)
        )
       



        #箭头引出
        arrow8 = Arrow(start=[23,-7,0],end=[28,-5,0], color=RED
                       , stroke_width=20, tip_length=1)

        #文本2
        text12= Tex(r"\text{万能公式}"
                   ,tex_template=TexTemplateLibrary.ctex).scale(5.0).move_to([33,-5,0])
        #箭头1引出
        arrow9 = Arrow(start=[23,-10,0],end=[28,-10,0], color=RED
                       , stroke_width=20, tip_length=1)

        #文本3
        text13 = Tex(r"\text{伪奇偶性}"
                   ,tex_template=TexTemplateLibrary.ctex).scale(5.0).move_to([33,-10,0])

        #箭头2引出
        arrow10 = Arrow(start=[23,-12,0],end=[28,-15,0], color=RED
                       , stroke_width=20, tip_length=1)
        #文本4
        text14 = Tex(r"\text{缩分母}"
                   ,tex_template=TexTemplateLibrary.ctex).scale(5.0).move_to([33,-15,0])

        #箭头3引出
        arrow11 = Arrow(start=[23,-14,0],end=[28,-20,0], color=RED
                       , stroke_width=20, tip_length=1)
        #文本5
        text15= Tex(r"\text{降幂}"
                   ,tex_template=TexTemplateLibrary.ctex).scale(5.0).move_to([33,-20 ,0])
        
        #集中展开
        self.play(Create(arrow11),Create(arrow10),Create(arrow9),Create(arrow8))
        self.play(Write(text15),Write(text14),Write(text13),Write(text12))



        #框框标记
        rectangle3=Rectangle(color=YELLOW,fill_opacity=0.0,width=90,height=45
                            ,stroke_color=YELLOW,stroke_width=20)
        rectangle3.move_to([0, 1, 0])
        self.play(Create(rectangle3))

        text16= Tex(r"\text{解题思路结构化}",color=BLUE
                   ,tex_template=TexTemplateLibrary.ctex).scale(5.0).next_to(rectangle3,UP,buff=1)
        self.play(Write(text16))

        self.wait(0.1)
        self.play(self.camera.frame.animate.scale(0.5).move_to([-2.5,20,0]))
        ##框框闪动

        rectangle4=Rectangle(color=BLUE,fill_opacity=0.0,width=11,height=5
                            ,stroke_color=BLUE,stroke_width=20)
        rectangle4.move_to([-2.5,20,0])
        self.play(Create(rectangle4))
        self.play(FadeOut(rectangle4))



        self.wait(1)
